package org.netty.push.client;

import org.netty.push.client.message.HandlerManagerFactory;
import org.netty.push.core.proto.codec.CodecFactory;

import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.handler.timeout.IdleStateHandler;

public class ClientChannelInitializer extends ChannelInitializer<Channel> {

	@Override
	protected void initChannel(Channel ch) throws Exception {
		ChannelPipeline pipeline = ch.pipeline();
		//检测心跳处理
		pipeline.addLast(new IdleStateHandler(0,10,0));
		//decodec and encoderc
		pipeline.addLast(CodecFactory.buildDecoder());
		pipeline.addLast(CodecFactory.buildEncoder());
		//data process
		pipeline.addLast(new ClientHandler(HandlerManagerFactory.buildHandler()));
	}

}
